var tmpPlayer = require("Player");   //引进猪脚对象
cc.Class({
    extends: cc.Component,

    properties: {
        
    },
    setInputControl: function(){
        var self= this;
        var listener = {
            event: cc.EventListener.TOUCH_ONE_BY_ONE,
            onTouchBegan: function (touches, event) {
                var goAction= cc.moveBy(0.2,cc.p(0,140));
                self.node.runAction(goAction);
                return true; //这里必须要写 return true
            },
            onTouchMoved: function (touches, event) {
              
            },
            onTouchEnded: function (touches, event) {
           
            },
            onTouchCancelled: function (touches, event) {
            }
        }
        cc.eventManager.addListener(listener, self.node);
    },

    noteBox:function(){
        return this.node.getBoundingBoxToWorld();  //得到地刺的盒子
    },

    onLoad () {
        this.setInputControl();
    },

    start () {

    },

    update (dt) {
        var player = cc.find("Canvas/normal").getComponent(tmpPlayer);   //引进player对象

        if(cc.rectIntersectsRect(player.node.getBoundingBoxToWorld(),this.noteBox())){
            cc.audioEngine.pauseMusic();
            cc.director.loadScene('OverScene');
           //cc.log('碰撞');
        }
    },
});
